﻿#ifndef XVIDEOWIDGET_H
#define XVIDEOWIDGET_H

#include <QObject>
#include <QWidget>
#include <QOpenGLWidget>
#include <QOpenGLFunctions>
#include <QOpenGLShaderProgram>
#include <mutex>

#include "ffmpeg.h"
#include "isrvideoshow.h"

class SrVideoWidget : public QOpenGLWidget,protected QOpenGLFunctions,public ISrVideoShow
{
    Q_OBJECT
public:
    SrVideoWidget();
    SrVideoWidget(QWidget *parent);

    ~SrVideoWidget();

    //
    virtual void Repaint(AVFrame *frame);


    void Init(int width, int height);
protected:
    //初始化opengl
     void initializeGL();
     //窗口发生变化
     void resizeGL(int w, int h);
     //刷新显示的
     void paintGL();
signals:

public slots:

private:
     //着色器 的容器
     QOpenGLShaderProgram program;

     GLuint textureUniformY; //y纹理数据位置
     GLuint textureUniformU; //u纹理数据位置
     GLuint textureUniformV; //v纹理数据位置

     //openg的 texture地址
     GLuint texs[3];

     int width = 240;
     int height = 128;

     //材质内存空间
     unsigned char *datas[3];

     std::mutex _mux;

    // FILE  *fp;

};

#endif // XVIDEOWIDGET_H
